class UserController < ApplicationController

  def index
    
  end

  def show
  end

  def new
      @user = User.new
  end

  def edit
  end
  
  def create
    @user = User.new(params[:user])
   
    if @user.save #== @user
      session[:user] = @user.id
      
      flash[:notice] = 'You are ready to start trading books'
      redirect_to :controller => "book", :action => "index"
    else
      flash[:notice] = 'Problem detected'
      render :action => "new"
    end
  end
  
  def update
    if @user.update_attributes(params[:user])
      flash[:notice] = 'User successfully updated'
      redirect_to :action => "show", :id =>@user.id
    else
      render :Acction => "edit"
    end
  end
  
  def destroy
    @user.destroy
    flash[:notice] = 'User account removed'
    redirect_to :action => "index"
  end
  
  def find_user
    @user = User.find(params[:id])
  end
  
  def login
    #form view
  end
  
  def authenticate
    if true
      session[:user] = 1
      
      flash[:notice] = 'You are ready to start trading books'
      redirect_to :controller => "book", :action => "index"
    else
      render :action => "login"
    end
  end
end
